<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
%>
<html>
<head>

<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/icon.css">
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/locale/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
	
	 $('#dg').datagrid({
         url:"<%=path%>/articleAction/getarticleDataGrid",
         //开启分页
         pagination : "true",
         //设置分页工具栏位置
         pagePosition : "bottom",
         //设置分页间隔
         pageList : [ 4, 8, 16 ],
         pageSize : 4,
         width : 480,
         //是否从服务器对数据进行排序
         //定义顶部工具栏的DataGrid面板
         //定义网格的标题
         toolbar : "#search",
         title : "用户管理",
         columns : [ [
         //定义列，这里有三列，每一列的都是一个对象，title为列标题，field为字段的名称
         {
             title : "",
             field : "ck",
             checkbox : true
         }, {
             title : "标题",
             field : "title",
            	 width : 150,
     			align : "center",

         }, {
             title : "作者",
             field : "author",
         	width : 150,
			align : "center",
          
             
         },{
				title:"操作",
				field:"sid",
				width : 150,
				align : "center",
				  formatter : function(value, row, index) {
					  return '<a href="#" onclick="look('+row["id"]+')"">查看内容</a> <a href="#" onclick="shenhe('+row["id"]+')"">审核</a> ';  
	                }
			}] ]

     });
	
})


		//搜素
		function doSearch(){
			var author=$("#author").val();
			$('#dg').datagrid({
                //queryParams方法在请求远程数据的时候发送额外的参数,参数一定要是json格式的对象，而表单序列化后是数组对象。需要将数组对象转为json格式的对象
                queryParams: {
                    "author":author
                }
            });
		}
		
		//查看文章内容
		function look(articleId){
			var URL="<%=path%>/articleAction/lookContentView?articleId="+articleId;
			
			var iWidth = 1000;
			var iHeight = 600;
			var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
			var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
			var win = window.open(URL, "弹出窗口", "width=" + iWidth + ", height=" + iHeight + ",top=" + iTop + ",left=" + iLeft + ",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,alwaysRaised=yes,depended=yes");
		}
				
		//审核文章
		function shenhe(articleId){
						$.ajax({
							 url:'<%=path%>/articleAction/shenhe',
							 type:'POST', 
							 data:{
								 articleId:articleId,
							    },
							 success:function(result){
								 $.messager.confirm('提示',result.msg,function(r){    
									 $('#dg').datagrid('reload',{
										});
									}); 
							    }
							
						})
		}

</script>



<body class="easyui-layout" >   

    <table id="dg"></table>
   
   	<div id="search" style="padding: 3px">
		<span>作者:</span> <input id="author"
			style="line-height: 20px; width:60px;border: 1px solid #ccc"> 
			<a href="#" class="easyui-linkbutton" style="margin-left: 75px;" data-options="iconCls:'icon-search'" plain="true" onclick="doSearch();">搜索</a>
	</div>
   
</body>  

</html>